package com.seepine.auth.entity;

import cn.hutool.crypto.symmetric.AES;

import java.util.concurrent.TimeUnit;

/**
 * auth参数类
 *
 * @author seepine
 */
public class AuthProperties {
    /**
     * 请求头参数
     */
    String header = "token";
    /**
     * 安全参数相关
     */
    String secretHeader = "secret";
    String secretKey = "secret_key";
    String secretIv = "secret_iv";
    long secretTimeout = 10000;

    /**
     * 缓存前缀
     */
    String cacheKey = "sm_auth:";
    /**
     * token过期时间数
     */
    long timeout = 5;
    /**
     * token过期时间类型
     */
    TimeUnit unit = TimeUnit.DAYS;
    /**
     * 是否自动重置token过期时间
     */
    Boolean resetTimeout = false;

    AES aes;

    public AuthProperties secretHeader(String secretHeader) {
        this.secretHeader = secretHeader;
        return this;
    }

    public AuthProperties secretTimeout(long secretTimeout) {
        this.secretTimeout = secretTimeout;
        return this;
    }

    public AuthProperties secret(String secretKey, String secretIv) {
        this.secretKey = secretKey;
        this.secretIv = secretIv;
        return this;
    }

    public AuthProperties secret(String secretHeader, String secretKey, String secretIv) {
        this.secretHeader = secretHeader;
        this.secretKey = secretKey;
        this.secretIv = secretIv;
        return this;
    }

    public AuthProperties header(String header) {
        this.header = header;
        return this;
    }

    public AuthProperties resetTimeout(Boolean resetTimeout) {
        this.resetTimeout = resetTimeout;
        return this;
    }

    public AuthProperties cacheKey(String cacheKey) {
        this.cacheKey = cacheKey;
        return this;
    }

    public AuthProperties timeout(long timeout) {
        this.timeout = timeout;
        return this;
    }

    public AuthProperties timeout(long timeout, TimeUnit unit) {
        this.timeout = timeout;
        this.unit = unit;
        return this;
    }

    public AuthProperties timeout(long timeout, TimeUnit unit, Boolean resetTimeout) {
        this.timeout = timeout;
        this.unit = unit;
        this.resetTimeout = resetTimeout;
        return this;
    }

    public String header() {
        return header;
    }

    public String secretHeader() {
        return secretHeader;
    }

    public long secretTimeout() {
        return secretTimeout;
    }

    public String secretKey() {
        return secretKey;
    }

    public String secretIv() {
        return secretIv;
    }

    public String cacheKey() {
        return cacheKey;
    }

    public long timeout() {
        return timeout;
    }

    public Boolean resetTimeout() {
        return resetTimeout;
    }

    public TimeUnit unit() {
        return unit;
    }

}
